#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QGraphicsDropShadowEffect>
#include <QPropertyAnimation>


MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //设备图片周围的阴影
    m_lblIdentityImgshadowEffect =new QGraphicsDropShadowEffect(this);
    m_lblIdentityImgshadowEffect->setColor(Qt::/*darkGreen*/red);
    m_lblIdentityImgshadowEffect->setOffset(0,0);
    m_lblIdentityImgshadowEffect->setBlurRadius(0);

//    m_lblSnapImgshadowEffect = new QGraphicsDropShadowEffect(this);
//    m_lblSnapImgshadowEffect->setColor(Qt::red);
//    m_lblSnapImgshadowEffect->setOffset(0,0);
//    m_lblSnapImgshadowEffect->setBlurRadius(0);

//    ui->lblIdentityImg->setText(QString::fromLocal8Bit("China"));
    ui->lblIdentityImg->setGraphicsEffect(m_lblIdentityImgshadowEffect);
    ui->lblIdentityImg->setPixmap(QPixmap("mask.png"));
//    ui->lblSnapImg->setGraphicsEffect(m_lblSnapImgshadowEffect);

    //抓拍图片的边框动画特效
//    m_lblSnapImgAnimation = new QPropertyAnimation();
//    m_lblSnapImgAnimation->setTargetObject(this);
//    m_lblSnapImgAnimation->setDuration(2000);
//    m_lblSnapImgAnimation->setPropertyName("iBorderRadius");
//    m_lblSnapImgAnimation->setKeyValueAt(0,1);
//    m_lblSnapImgAnimation->setKeyValueAt(0.5,30);
//    m_lblSnapImgAnimation->setKeyValueAt(1,1);

//    m_lblSnapImgAnimation->setLoopCount(-1);

    //身份证照片的边框动画特效
    m_lblIdentityImgAnimation = new QPropertyAnimation();
    m_lblIdentityImgAnimation->setTargetObject(this);
    m_lblIdentityImgAnimation->setDuration(2000);
    m_lblIdentityImgAnimation->setPropertyName("iBorderRadius");
    m_lblIdentityImgAnimation->setKeyValueAt(0,1);
    m_lblIdentityImgAnimation->setKeyValueAt(0.5,30);
    m_lblIdentityImgAnimation->setKeyValueAt(1,1);

    m_lblIdentityImgAnimation->setLoopCount(-1);

//    connect(this, SIGNAL(StartLableAnimation()), m_lblSnapImgAnimation, SLOT(start()));

    connect(this, SIGNAL(StartLableAnimation()), m_lblIdentityImgAnimation, SLOT(start()));

//    setBorderRadius(100);

    emit StartLableAnimation();
}

MainWindow::~MainWindow()
{
    delete ui;
}

int MainWindow::iBorderRadius() const
{
    return m_borderRadius;
}

void MainWindow::setBorderRadius(const int radius)
{
    m_borderRadius = radius;

//    m_lblSnapImgshadowEffect->setBlurRadius(m_borderRadius);
    m_lblIdentityImgshadowEffect->setBlurRadius(m_borderRadius);
}
